<%@ page import="com.pension.model.dto.Room"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
	Room room = (Room)request.getAttribute("room");
%>
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<title>EDIT ROOM</title>
<link rel="Stylesheet" href="/pension/styles/default.css" />
<link rel="Stylesheet" href="/pension/styles/input.css" />
<script type="text/javascript">
	function checkAndSubmit() {
		var message ="";
		var roomnumber = document.getElementById("roomnumber");
		if (roomnumber.value.length == 0) {
			message += "호수를 입력해주세요.\r\n";
		}
		
		var roomname = document.getElementById("roomname");
		if (roomname.value.length == 0) {
			message += "방이름을 입력해주세요.\r\n";
		}
		//var re = new RegExp("^[0-9A-Za-z]{5,20}$");
		
		var re = /^[A-Za-z]{1,20}$/;
		if (!re.test(roomname.value)) {0
			message += "방이름을 영문자(대소문자)으로 1자 이상 ,20자 이하로 입력해주세요.\r\n"
		}
		
		var maxpeople = document.getElementById("maxpeople");
		var re1 = /^[0-9]{1,11}$/;
		if (!re1.test(maxpeople.value)) {
			message += "숫자만입력해주세요(최대인원).\r\n";
		}
		
		var acreagesize = document.getElementById("acreagesize");
		var re2 = /^[0-9]{1,11}$/;
		if (!re2.test(acreagesize.value)) {
			message += "숫자만입력해주세요(평수).\r\n";
		}
		
		var priceroom = document.getElementById("priceroom");
		var re3 = /^[0-9]{1,11}$/;
		if (!re3.test(priceroom.value)) {
			message += "숫자만입력해주세요(가격).\r\n";
		}
		
		if (message.length > 0) {
			alert(message);
		} else {
		document.getElementById("update").submit();
		}
	}
</script>
</head>
<body>

	<div id="pageContainer">

		<%
			pageContext.include("/WEB-INF/views/include/header.jsp");
		%>

		<div id="inputcontent">
			<br />
			<br />
			<div id="inputmain">
				<div class="inputsubtitle">BASIC ROOM INFO</div>

				<form id="update" action="/pension/room/update.action"
					method="post">
					<!-- 상대경로표시 -->
					<table>
						<tr>
							<th>호수</th>
							<td>
							<input type="text" readonly="readonly" id="roomnumber" name="roomnumber"
								style="width: 280px" value="<%= room.getRoomNumber()  %>" /></td>
						</tr>
						<tr>
							<th>방이름</th>
							<td><input type="text" id="roomname" name="roomname"
								style="width: 280px" value="<%= room.getRoomName() %>" /></td>
						</tr>
						<tr>
							<th>구분</th>
							<td><input type="text" id="roomtype" name="roomtype" style="width: 280px" value="<%= room.getRoomType() %>" />
							</td>
						</tr>
						<tr>
							<th>최대인원</th>
							<td><input type="text" id="maxpeople" name="maxpeople" style="width: 280px" value="<%= room.getMaxPeople() %>" />
							</td>
						</tr>
						<tr>
							<th>평수</th>
							<td><input type="text" id="acreagesize" name="acreagesize"
								style="width: 280px" value="<%= room.getAcreageSize() %>" /></td>
						</tr>
						<tr>
							<th>가격</th>
							<td><input type="text" id="priceroom" name="priceroom" style="width: 280px" value="<%= room.getPriceRoom() %>" />
							</td>
						</tr>
					</table>
					<div class="buttons">
						<input type="button" value="수정" style="height: 25px"
							onclick="checkAndSubmit();" /> <input type="button" value="취소"
							style="height: 25px"
							onclick="location.href='/pension/room/admin.action';" />
					</div>
				</form>
			</div>
		</div>

	</div>

</body>
</html>